package com.yfp.machine.aspect;

import com.yfp.machine.service.MachineService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * 刷新地理缓存切面
 *
 * 
 * @date 2023/12/19
 */
@Aspect
@Component
@Slf4j
public class RefreshGeoCacheAspect {

    @Resource
    MachineService machineService;

    @Pointcut("@annotation(annotation.com.yfp.machine.RefreshGeoCache)")
    public void refreshGeoCache() {}

    @AfterReturning(value = "refreshGeoCache()", returning = "result")
    public Object refreshGeoCache(Object result) {
        machineService.resetConfigCache();
        log.info("切面执行成功,设备缓存刷新完毕.");
        return result;
    }
}
